package com.battle.pojo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import nirvana.core.domains.enums.Enums;

/**
 * @author anni.zhu
 * @author anni.zhu@king-v.com
 * Created in 2024/8/22 15:02
 * 组织架构类型
 *
 * 一级：杭州支队
 * 二级：处室部门或者大队
 * 三级：中队 （只允许大队下面挂中队）
 */
@Getter
@AllArgsConstructor
public enum OrganizationTypeEnum implements Enums<OrganizationTypeEnum> {
    detachment(0,"支队"),
    department(1,"处室部门"),
    big_detachment(2,"大队"),
    middleDetachment(3,"中队"),
    none(4,"无"),
    ;
    @JsonValue
    @EnumValue
    private Integer id;
    private String name;

    public static String getNameByCode(Integer code) {
        OrganizationTypeEnum[] values = OrganizationTypeEnum.values ();
        for (OrganizationTypeEnum value : values) {
            if (value.getId().equals(code) ) {
                return value.name;
            }
        }
        return null;
    }

    public static String getCodeByName(String Name) {
        OrganizationTypeEnum[] values = OrganizationTypeEnum.values ();
        for (OrganizationTypeEnum value : values) {
            if (value.name.equals(Name)) {
                return value.name;
            }
        }
        return null;
    }

    public static OrganizationTypeEnum getEnumByName(String Name) {
        OrganizationTypeEnum[] values = OrganizationTypeEnum.values ();
        for (OrganizationTypeEnum value : values) {
            if (value.name.equals(Name)) {
                return value;
            }
        }
        return null;
    }
}
